package com.xsherl.leetcode.solution;

/**
 * @Author: sherl
 * @Date: 2021/5/24 20:54
 */
public class HammingWeight {

    public int hammingWeight(int n) {
        int i = 0;
        while (n != 0){
            n = n & n - 1;
            i++;
        }
        return i;
    }

}
